package com.qdu.servlet;

import com.qdu.entity.Book;
import com.qdu.service.BookService;
import com.qdu.service.impl.BookServiceImpl;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 该Servlet负责处理修改学生信息的请求
 *
 * @author Anna
 */
@WebServlet("/mbs")
public class ModifyBookServlet extends HttpServlet {
    
    BookService bookService = new BookServiceImpl();

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        
        //1. 获取请求参数
        
        req.setCharacterEncoding("utf-8");
        String bId = req.getParameter("bId");
       String bName = req.getParameter("bName");
         float brating = Float.parseFloat(req.getParameter("brating"));

//        System.out.println("1"+ bId);
//        System.out.println("1"+ bName);
//        System.out.println("1"+ brating);
        
        Book book = new Book(bId,bName,brating);

        //2. 调用业务逻辑，完成请求处理
        //修改学生姓名和性别
        int rows=bookService.modifyBookInfo(book);
        
        //3. 生成响应内容，这里返回受影响的行数用于判断是否修改成功
        resp.getWriter().print(rows);
        
    }
}
